package com.horsen.controller;

import com.horsen.model.User;
import com.horsen.service.UserService;
import com.horsen.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户管理")
@CrossOrigin
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @ApiImplicitParam(name = "id", value = "用户ID", required = true)
    @ApiOperation("根据ID查询一个用户")
    @GetMapping("/{id}")
    public R queryUserById(@PathVariable("id") Integer id) {
        User user = userService.queryUserById(id);
        return R.success().setData("user", user);
    }
}
